
*************************************************
*************************************************
***The Swing Justice
***Peter K. Enns and Patrick Wohlfarth
***The Journal of Politics 2013
*************************************************
*************************************************

**********************************************
**Replication Files for Supplementary Appendix
**********************************************

************************
**NOTE: Must set the working directory
************************
cd ""

set mem 15000k
use "swingJustice_jopFINpub.dta"

pause on

***********************
*FIGURE A-1
***********************
******
*All Reversals
******
**all
egen cplib_allzallr = std(cp_reclib) if reversal==1 & term<2008 & totalVotes==9
logit libvote sgconslib mood5208  cplib_allzallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & totalVotes==9, cluster(term)
margeff
**sw_medmq8
egen cplib_swmed8zallr = std(cp_reclib) if reversal==1 & sw_medmq8==1 & term<2008
logit libvote sgconslib mood5208 cplib_swmed8zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & sw_medmq8==1, cluster(term)
margeff
**sw_notmedmq8
egen cplib_swnotmed8zallr = std(cp_reclib) if reversal==1 & sw_notmedmq8==1 & term<2008
logit libvote sgconslib mood5208  cplib_swnotmed8zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & sw_notmedmq8==1, cluster(term)
margeff
**pos4mq8
egen cplib_pos48zallr = std(cp_reclib) if reversal == 1 & term<2008 & pos4mq8==1
logit libvote sgconslib mood5208  cplib_pos48zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & pos4mq8==1, cluster(term)
margeff
**pos3mq8
egen cplib_pos38zallr = std(cp_reclib) if reversal == 1 & term<2008 & pos3mq8==1
logit libvote sgconslib mood5208  cplib_pos38zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & pos3mq8==1, cluster(term)
margeff
**pos2mq8
egen cplib_pos28zallr = std(cp_reclib) if reversal == 1 & term<2008 & pos2mq8==1
logit libvote sgconslib mood5208  cplib_pos28zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & pos2mq8==1, cluster(term)
margeff
**pos1mq8
egen cplib_pos18zallr = std(cp_reclib) if reversal == 1 & term<2008 & pos1mq8==1
logit libvote sgconslib mood5208  cplib_pos18zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & pos1mq8==1, cluster(term)
margeff
drop cplib_allzallr cplib_swmed8zallr cplib_swnotmed8zallr cplib_pos48zallr cplib_pos38zallr cplib_pos28zallr cplib_pos18zallr 

**type "q" to continue do file
pause

******
*All Cases
******
**all
egen cplib_allzall = std(cp_reclib) if term<2008 & totalVotes==9
logit libvote sgconslib mood5208  cplib_allzall zsop_phmsm judpower economics civillib if term<2008 & totalVotes==9, cluster(term)
margeff
**sw_medmq8
egen cplib_swmed8zall = std(cp_reclib) if sw_medmq8==1 & term<2008
logit libvote sgconslib mood5208  cplib_swmed8zall zsop_phmsm judpower economics civillib if term<2008 & sw_medmq8==1, cluster(term)
margeff
**sw_notmedmq8
egen cplib_swnotmed8zall = std(cp_reclib) if sw_notmedmq8==1 & term<2008
logit libvote sgconslib mood5208  cplib_swnotmed8zall zsop_phmsm judpower economics civillib if term<2008 & sw_notmedmq8==1, cluster(term)
margeff
**pos4mq8
egen cplib_pos48zall = std(cp_reclib) if term<2008 & pos4mq8==1
logit libvote sgconslib mood5208  cplib_pos48zall zsop_phmsm judpower economics civillib if term<2008 & pos4mq8==1, cluster(term)
margeff
**pos3mq8
egen cplib_pos38zall = std(cp_reclib) if term<2008 & pos3mq8==1
logit libvote sgconslib mood5208  cplib_pos38zall zsop_phmsm judpower economics civillib if term<2008 & pos3mq8==1, cluster(term)
margeff
**pos2mq8
egen cplib_pos28zall = std(cp_reclib) if term<2008 & pos2mq8==1
logit libvote sgconslib mood5208  cplib_pos28zall zsop_phmsm judpower economics civillib if term<2008 & pos2mq8==1, cluster(term)
margeff
**pos1mq8
egen cplib_pos18zall = std(cp_reclib) if term<2008 & pos1mq8==1
logit libvote sgconslib mood5208  cplib_pos18zall zsop_phmsm judpower economics civillib if term<2008 & pos1mq8==1, cluster(term)
margeff
drop cplib_allzall cplib_swmed8zall cplib_swnotmed8zall cplib_pos48zall cplib_pos38zall cplib_pos28zall cplib_pos18zall 

**type "q" to continue do file
pause

***********************
**FIGURE A-2
***********************
********
**Reversals, 5-4 Decisions
********
**all
egen cplib_allz54r = std(cp_reclib) if reversal==1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_allz54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008, cluster(term)
margeff
**sw_medmq8
egen cplib_swmed8z54r = std(cp_reclib) if  sw_medmq8==1 & reversal == 1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_swmed8z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & sw_medmq8==1, cluster(term)
margeff
**sw_notmedmq8
egen cplib_swnotmed8z54r = std(cp_reclib) if sw_notmedmq8==1 & reversal == 1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_swnotmed8z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & sw_notmedmq8==1, cluster(term)
margeff
**pos4mq8
egen cplib_pos48z54r = std(cp_reclib) if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos4mq8==1
logit libvote sgconslib mood5208  cplib_pos48z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos4mq8==1, cluster(term)
margeff
**pos3mq8
egen cplib_pos38z54r = std(cp_reclib) if pos3mq8==1 & reversal == 1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_pos38z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos3mq8==1, cluster(term)
margeff
**pos2mq8
egen cplib_pos28z54r = std(cp_reclib) if pos2mq8==1 & reversal == 1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_pos28z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos2mq8==1, cluster(term)
margeff
**pos1mq8
egen cplib_pos18z54r = std(cp_reclib) if pos1mq8==1 & reversal == 1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_pos18z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos1mq8==1, cluster(term)
margeff
drop cplib_allz54r cplib_swmed8z54r cplib_swnotmed8z54r cplib_pos48z54r cplib_pos38z54r cplib_pos28z54r cplib_pos18z54r 

**type "q" to continue do file
pause
*******
**All Cases, 5-4 Decisions
*******
**all
egen cplib_allz54a = std(cp_reclib) if majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_allz54a  judpower economics civillib zsop_phmsm if majVote==5 & minVote==4 & term<2008, cluster(term)
margeff
**sw_medmq8
egen cplib_swmed8z54a = std(cp_reclib) if  sw_medmq8==1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_swmed8z54a  judpower economics civillib zsop_phmsm if majVote==5 & minVote==4 & term<2008 & sw_medmq8==1, cluster(term)
margeff
**sw_notmedmq8
egen cplib_swnotmed8z54a = std(cp_reclib) if sw_notmedmq8==1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_swnotmed8z54a  judpower economics civillib zsop_phmsm if majVote==5 & minVote==4 & term<2008 & sw_notmedmq8==1, cluster(term)
margeff
**pos4mq8
egen cplib_pos48z54a = std(cp_reclib) if majVote==5 & minVote==4 & term<2008 & pos4mq8==1
logit libvote sgconslib mood5208  cplib_pos48z54a  judpower economics civillib zsop_phmsm if majVote==5 & minVote==4 & term<2008 & pos4mq8==1, cluster(term)
margeff
**pos3mq8
egen cplib_pos38z54a = std(cp_reclib) if pos3mq8==1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_pos38z54a  judpower economics civillib zsop_phmsm if majVote==5 & minVote==4 & term<2008 & pos3mq8==1, cluster(term)
margeff
**pos2mq8
egen cplib_pos28z54a = std(cp_reclib) if pos2mq8==1 & majVote==5 & minVote==4 & term<2008
logit 
logit libvote sgconslib mood5208  cplib_pos28z54a  judpower economics civillib zsop_phmsm if majVote==5 & minVote==4 & term<2008 & pos2mq8==1, cluster(term)
margeff
**pos1mq8
egen cplib_pos18z54a = std(cp_reclib) if pos1mq8==1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_pos18z54a  judpower economics civillib zsop_phmsm if majVote==5 & minVote==4 & term<2008 & pos1mq8==1, cluster(term)
margeff
drop cplib_allz54a cplib_swmed8z54a cplib_swnotmed8z54a cplib_pos48z54a cplib_pos38z54a cplib_pos28z54a cplib_pos18z54a 

**type "q" to continue do file
pause

*****************
**TABLE A-1
**ALL REVERSALS
*****************
**all
egen cplib_allzallr = std(cp_reclib) if reversal==1 & term<2008 & totalVotes==9
logit libvote sgconslib mood5208  cplib_allzallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & totalVotes==9, cluster(term)
**sw_medmq8
egen cplib_swmed8zallr = std(cp_reclib) if reversal==1 & sw_medmq8==1 & term<2008
logit libvote sgconslib mood5208  cplib_allzallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & sw_medmq8==1, cluster(term)
**sw_notmedmq8
egen cplib_swnotmed8zallr = std(cp_reclib) if reversal==1 & sw_notmedmq8==1 & term<2008
logit libvote sgconslib mood5208  cplib_swnotmed8zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & sw_notmedmq8==1, cluster(term)
**pos4mq8
egen cplib_pos48zallr = std(cp_reclib) if reversal == 1 & term<2008 & pos4mq8==1
logit libvote sgconslib mood5208  cplib_pos48zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & pos4mq8==1, cluster(term)
**pos3mq8
egen cplib_pos38zallr = std(cp_reclib) if reversal == 1 & term<2008 & pos3mq8==1
logit libvote sgconslib mood5208  cplib_pos38zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & pos3mq8==1, cluster(term)
**pos2mq8
egen cplib_pos28zallr = std(cp_reclib) if reversal == 1 & term<2008 & pos2mq8==1
logit libvote sgconslib mood5208  cplib_pos28zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & pos2mq8==1, cluster(term)
**pos1mq8
egen cplib_pos18zallr = std(cp_reclib) if reversal == 1 & term<2008 & pos1mq8==1
logit libvote sgconslib mood5208  cplib_pos18zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & pos1mq8==1, cluster(term)

**type "q" to continue do file
pause
*****************
**TABLE A-2
**5-4 REVERSALS
*****************
**all
egen cplib_allz54r = std(cp_reclib) if reversal==1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_allz54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008, cluster(term)
**sw_medmq8
egen cplib_swmed8z54r = std(cp_reclib) if  sw_medmq8==1 & reversal == 1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_swmed8z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & sw_medmq8==1, cluster(term)
**sw_notmedmq8
egen cplib_swnotmed8z54r = std(cp_reclib) if sw_notmedmq8==1 & reversal == 1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_swnotmed8z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & sw_notmedmq8==1, cluster(term)
**pos4mq8
egen cplib_pos48z54r = std(cp_reclib) if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos4mq8==1
logit libvote sgconslib mood5208  cplib_pos48z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos4mq8==1, cluster(term)
**pos3mq8
egen cplib_pos38z54r = std(cp_reclib) if pos3mq8==1 & reversal == 1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_pos38z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos3mq8==1, cluster(term)
**pos2mq8
egen cplib_pos28z54r = std(cp_reclib) if pos2mq8==1 & reversal == 1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_pos28z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos2mq8==1, cluster(term)
**pos1mq8
egen cplib_pos18z54r = std(cp_reclib) if pos1mq8==1 & reversal == 1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_pos18z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos1mq8==1, cluster(term)

**type "q" to continue do file
pause


************************************************************************************
****************************
****************************
***SOP Robustness Checks
****************************
****************************
************************************************************************************


****************************
**Reversals, ALL Decisions
**FIGURE A-3(a)
****************************

************
**Standard Model, SOP=zsop_phmsm (president, house median, senate median)
************
**all
logit libvote zsop_phmsm cplib_allzallr mood5208   sgconslib judpower economics civillib if reversal == 1 & term<2008 & totalVotes==9, cluster(term)
margeff
**sw_medmq8
logit libvote zsop_phmsm cplib_swmed8zallr mood5208   sgconslib judpower economics civillib if reversal == 1 & term<2008 & sw_medmq8==1, cluster(term)
margeff
**sw_notmedmq8
logit libvote zsop_phmsm cplib_swnotmed8zallr mood5208   sgconslib judpower economics civillib if reversal == 1 & term<2008 & sw_notmedmq8==1, cluster(term)
margeff

**type "q" to continue do file
pause
************
**SOP= zsop_pfp (president, filibuster pivot)
************
**all
logit libvote zsop_pfp cplib_allzallr mood5208   sgconslib judpower economics civillib if reversal == 1 & term<2008 & totalVotes==9, cluster(term)
margeff
**sw_medmq8
logit libvote zsop_pfp cplib_swmed8zallr mood5208   sgconslib judpower economics civillib if reversal == 1 & term<2008 & sw_medmq8==1, cluster(term)
margeff
**sw_notmedmq8
logit libvote zsop_pfp cplib_swnotmed8zallr mood5208   sgconslib judpower economics civillib if reversal == 1 & term<2008 & sw_notmedmq8==1, cluster(term)
margeff

**type "q" to continue do file
pause
************
**SOP=zsop_phpsp (president, house party, senate party)
************
**all
logit libvote zsop_phpsp cplib_allzallr mood5208   sgconslib judpower economics civillib  if reversal == 1 & term<2008 & totalVotes==9, cluster(term)
margeff
**sw_medmq8
logit libvote zsop_phpsp cplib_swmed8zallr mood5208   sgconslib judpower economics civillib if reversal == 1 & term<2008 & sw_medmq8==1, cluster(term)
margeff
**sw_notmedmq8
logit libvote zsop_phpsp cplib_swnotmed8zallr mood5208   sgconslib judpower economics civillib  if reversal == 1 & term<2008 & sw_notmedmq8==1, cluster(term)
margeff

drop cplib_allzallr cplib_swmed8zallr cplib_swnotmed8zallr cplib_pos48zallr cplib_pos38zallr cplib_pos28zallr cplib_pos18zallr 

**type "q" to continue do file
pause
****************************
**Reversals, 5-4 Decisions
**FIGURE A-3(b)
****************************

************
**Standard Model, SOP=zsop_phmsm (president, house median, senate median)
************
**all
logit libvote zsop_phmsm cplib_allz54r mood5208   sgconslib judpower economics civillib if reversal == 1 & majVote==5 & minVote==4 & term<2008, cluster(term)
margeff
**sw_medmq8
logit libvote zsop_phmsm cplib_swmed8z54r mood5208   sgconslib judpower economics civillib if reversal == 1 & majVote==5 & minVote==4 & term<2008 & sw_medmq8==1, cluster(term)
margeff
**sw_notmedmq8
logit libvote zsop_phmsm cplib_swnotmed8z54r mood5208   sgconslib judpower economics civillib if reversal == 1 & majVote==5 & minVote==4 & term<2008 & sw_notmedmq8==1, cluster(term)
margeff

**type "q" to continue do file
pause
************
**SOP= zsop_pfp (president, filibuster pivot)
************
**all
logit libvote zsop_pfp cplib_allz54r mood5208   sgconslib judpower economics civillib if reversal == 1 & majVote==5 & minVote==4 & term<2008, cluster(term)
margeff
**sw_medmq8
logit libvote zsop_pfp cplib_swmed8z54r mood5208   sgconslib judpower economics civillib if reversal == 1 & majVote==5 & minVote==4 & term<2008 & sw_medmq8==1, cluster(term)
margeff
**sw_notmedmq8
logit libvote zsop_pfp cplib_swnotmed8z54r mood5208   sgconslib judpower economics civillib if reversal == 1 & majVote==5 & minVote==4 & term<2008 & sw_notmedmq8==1, cluster(term)
margeff

**type "q" to continue do file
pause
************
**SOP=zsop_phpsp (president, house party, senate party)
************
**all
logit libvote zsop_phpsp cplib_allz54r mood5208   sgconslib judpower economics civillib  if reversal == 1 & majVote==5 & minVote==4 & term<2008, cluster(term)
margeff
**sw_medmq8
logit libvote zsop_phpsp cplib_swmed8z54r mood5208   sgconslib judpower economics civillib if reversal == 1 & majVote==5 & minVote==4 & term<2008 & sw_medmq8==1, cluster(term)
margeff
**sw_notmedmq8
logit libvote zsop_phpsp cplib_swnotmed8z54r mood5208   sgconslib judpower economics civillib  if reversal == 1 & majVote==5 & minVote==4 & term<2008 & sw_notmedmq8==1, cluster(term)
margeff

drop cplib_allz54r cplib_swmed8z54r cplib_swnotmed8z54r cplib_pos48z54r cplib_pos38z54r cplib_pos28z54r cplib_pos18z54r 

**type "q" to continue do file
pause

************************************************************************************
****************************
****************************
***IDEOLOGY Robustness Checks
****************************
****************************
************************************************************************************




****************************************************
***Cameron Park and Segal Cover scores
***Analyzing Civil Liberty Cases Only (following Segal and Cover 1989),
***because these cases offer a best case scenario for the attitudinal model
**FIGURE A-4
****************************************************

***********
**All Reversals
***********

**Cameron Park(all reversals, all justices)
egen zcp_allr_civlib = std(cp_reclib) if reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008 & totalVotes==9
logit libvote zsop_phmsm zcp_allr_civlib mood5208 sgconslib if reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008 & totalVotes==9, cluster(term)
margeff
**Segal Cover (all reversals, all justices)
egen zsc_allr_civlib = std(segalcover) if reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008 & totalVotes==9
logit libvote zsop_phmsm zsc_allr_civlib mood5208 sgconslib if reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008 & totalVotes==9, cluster(term)
margeff

**Cameron Park(all reversals, median swing justice)
egen zcp_medmq8allr_civlib = std(cp_reclib) if sw_medmq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008
logit libvote zsop_phmsm zcp_medmq8allr_civlib mood5208 sgconslib if sw_medmq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008, cluster(term)
margeff
**Segal Cover (all reversals, median swing justice)
egen zsc_medmq8allr_civlib = std(segalcover) if sw_medmq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008
logit libvote zsop_phmsm zsc_medmq8allr_civlib mood5208 sgconslib if sw_medmq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008, cluster(term)
margeff

**Cameron Park(all reversals, ideological swing justice)
egen zcp_notmedmq8allr_civlib = std(cp_reclib) if sw_notmedmq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008
logit libvote zsop_phmsm zcp_notmedmq8allr_civlib mood5208 sgconslib if sw_notmedmq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008, cluster(term)
margeff
**Segal Cover (all reversals, ideological swing justice)
egen zsc_notmedmq8allr_civlib = std(segalcover) if sw_notmedmq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008
logit libvote zsop_phmsm zsc_notmedmq8allr_civlib mood5208 sgconslib if sw_notmedmq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008, cluster(term)
margeff

**type "q" to continue do file
pause

**Cameron Park(all reversals, position 4)
egen zcp_pos4mq8allr_civlib = std(cp_reclib) if pos4mq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008
logit libvote zsop_phmsm zcp_pos4mq8allr_civlib mood5208 sgconslib if pos4mq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008, cluster(term)
margeff
**Segal Cover (all reversals, position 4)
egen zsc_pos4mq8allr_civlib = std(segalcover) if pos4mq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008
logit libvote zsop_phmsm zsc_pos4mq8allr_civlib mood5208 sgconslib if pos4mq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008, cluster(term)
margeff

**Cameron Park(all reversals, position 3)
egen zcp_pos3mq8allr_civlib = std(cp_reclib) if pos3mq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008
logit libvote zsop_phmsm zcp_pos3mq8allr_civlib  mood5208 sgconslib if pos3mq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008, cluster(term)
margeff
**Segal Cover (all reversals, position 3)
egen zsc_pos3mq8allr_civlib = std(segalcover) if pos3mq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008
logit libvote zsop_phmsm zsc_pos3mq8allr_civlib  mood5208 sgconslib if pos3mq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008, cluster(term)
margeff

**Cameron Park(all reversals, position 2)
egen zcp_pos2mq8allr_civlib = std(cp_reclib) if pos2mq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008
logit libvote zsop_phmsm zcp_pos2mq8allr_civlib  mood5208 sgconslib if pos2mq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008, cluster(term)
margeff
**Segal Cover (all reversals, position 2)
egen zsc_pos2mq8allr_civlib = std(segalcover) if pos2mq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008
logit libvote zsop_phmsm zsc_pos2mq8allr_civlib  mood5208 sgconslib if pos2mq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008, cluster(term)
margeff

**Cameron Park(all reversals, position 1)
egen zcp_pos1mq8allr_civlib = std(cp_reclib) if pos1mq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008
logit libvote zsop_phmsm zcp_pos1mq8allr_civlib  mood5208 sgconslib if pos1mq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008, cluster(term)
margeff
**Segal Cover (all reversals, position 1)
egen zsc_pos1mq8allr_civlib = std(segalcover) if pos1mq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008
logit libvote zsop_phmsm zsc_pos1mq8allr_civlib  mood5208 sgconslib if pos1mq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008, cluster(term)
margeff

**Test for equivlaent AME for ideology w/ SC score
logit libvote zsop_phmsm zsc_allr_civlib mood5208 sgconslib if reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008 & totalVotes==9
margeff
est store amescall
logit libvote zsop_phmsm zsc_medmq8allr_civlib mood5208 sgconslib if sw_medmq8==1 & reversal == 1 & issueArea>=1 & issueArea<=5 & term<2008
margeff
est store amescmsj
suest amescall amescmsj, cluster(term)
**For Stata 10 and earlier
*test [amescall]zsc_allr_civlib=[amescmsj]zsc_medmq8allr_civlib 
**For Stata 11 and later
*test [amescall_libvote]zsc_allr_civlib=[amescmsj_libvote]zsc_medmq8allr_civlib 

drop zcp_pos1mq8allr_civlib zcp_pos2mq8allr_civlib zcp_pos3mq8allr_civlib zcp_pos4mq8allr_civlib zcp_notmedmq8allr_civlib zcp_medmq8allr_civlib zcp_allr_civlib 
drop zsc_pos1mq8allr_civlib zsc_pos2mq8allr_civlib zsc_pos3mq8allr_civlib zsc_pos4mq8allr_civlib zsc_notmedmq8allr_civlib zsc_medmq8allr_civlib zsc_allr_civlib 

**type "q" to continue do file
pause


**************************************
**************************************
***MQ by issue area to avoid endogeneity concerns
***FIGURE A-5
**************************************
**************************************

*******************
***ALL JUSTICES
*******************

**Standardize ideology measures so comparable across different models
egen zmq4_civlib_allr = std(mqFour_civilLib) if reversal == 1 & term<2008 & issueArea!=3 & issueArea!=4 & issueArea!=5 & issueArea!=6 & totalVotes==9
egen zmq4_civrts_allr = std(mqFour_civilRights) if reversal == 1 & term<2008 & issueArea!=2 & totalVotes==9
egen zmq4_crimproc_allr = std(mqFour_crimProcedure) if reversal == 1 & term<2008 & issueArea!=1 & totalVotes==9
egen zmq4_econ_allr = std(mqFour_Economic) if reversal == 1 & term<2008 & issueArea<7 & totalVotes==9

**MQ Econ/Other, predicting non-econ/other (all reversals)
logit libvote zsop_phmsm zmq4_econ_allr mood5208 sgconslib judpower economics civillib if reversal == 1 & term<2008 & issueArea<7 & totalVotes==9, cluster(term)
margeff

**MQ Criminal Proc, predicing non-crim proc. (all reversals)
logit libvote zsop_phmsm zmq4_crimproc_allr mood5208 sgconslib judpower economics civillib if reversal == 1 & term<2008 & issueArea!=1 & totalVotes==9, cluster(term)
margeff

**MQ civil lib, predicting non-civil lib cases (all reversals)
logit libvote zsop_phmsm zmq4_civlib_allr mood5208 sgconslib judpower economics civillib if reversal == 1 & term<2008 & issueArea!=3 & issueArea!=4 & issueArea!=5 & issueArea!=6 & totalVotes==9, cluster(term)
margeff

**MQ civil rights, predicting non-civil rts (all reversals)
logit libvote zsop_phmsm zmq4_civrts_allr mood5208 sgconslib judpower economics civillib if reversal == 1 & term<2008 & issueArea!=2 & totalVotes==9, cluster(term)
margeff

drop zmq4_civlib_allr zmq4_civrts_allr zmq4_crimproc_allr zmq4_econ_allr 

**type "q" to continue do file
pause

*******************
***MEDIAN SWING JUSTICE
*******************

**Standardize ideology measures so comparable across different models
egen zmq4_civlib_medr = std(mqFour_civilLib) if sw_medmq8==1 & reversal == 1 & term<2008 & issueArea!=3 & issueArea!=4 & issueArea!=5 & issueArea!=6
egen zmq4_civrts_medr = std(mqFour_civilRights) if sw_medmq8==1 & reversal == 1 & term<2008 & issueArea!=2
egen zmq4_crimproc_medr = std(mqFour_crimProcedure) if sw_medmq8==1 & reversal == 1 & term<2008 & issueArea!=1
egen zmq4_econ_medr = std(mqFour_Economic) if sw_medmq8==1 & reversal == 1 & term<2008 & issueArea<7


**MQ civil lib, predicting non-civil lib cases (all reversals)
logit libvote zsop_phmsm zmq4_civlib_medr mood5208 sgconslib judpower economics civillib if sw_medmq8==1 & reversal == 1 & term<2008 & issueArea!=3 & issueArea!=4 & issueArea!=5 & issueArea!=6, cluster(term)
margeff

**MQ civil rights, predicting non-civil rts (all reversals)
logit libvote zsop_phmsm  zmq4_civrts_medr mood5208 sgconslib judpower economics civillib if sw_medmq8==1 & reversal == 1 & term<2008 & issueArea!=2, cluster(term)
margeff

**MQ Criminal Proc, predicing non-crim proc. (all reversals)
logit libvote zsop_phmsm zmq4_crimproc_medr mood5208 sgconslib judpower economics civillib if sw_medmq8==1 & reversal == 1 & term<2008 & issueArea!=1, cluster(term)
margeff

**MQ Econ/Other, predicting non-econ/other (all reversals)
logit libvote zsop_phmsm zmq4_econ_medr mood5208 sgconslib judpower economics civillib if sw_medmq8==1 & reversal == 1 & term<2008 & issueArea<7, cluster(term)
margeff

drop zmq4_civlib_medr zmq4_civrts_medr zmq4_crimproc_medr zmq4_econ_medr 

**type "q" to continue do file
pause
*******************
***IDEOLOGICAL SWING JUSTICE
*******************

**Standardize ideology measures so comparable across different models
egen zmq4_civlib_notmedr = std(mqFour_civilLib) if sw_notmedmq8==1 & reversal == 1 & term<2008 & issueArea!=3 & issueArea!=4 & issueArea!=5 & issueArea!=6
egen zmq4_civrts_notmedr = std(mqFour_civilRights) if sw_notmedmq8==1 & reversal == 1 & term<2008 & issueArea!=2
egen zmq4_crimproc_notmedr = std(mqFour_crimProcedure) if sw_notmedmq8==1 & reversal == 1 & term<2008 & issueArea!=1
egen zmq4_econ_notmedr = std(mqFour_Economic) if sw_notmedmq8==1 & reversal == 1 & term<2008 & issueArea<7

**MQ civil rights, predicting non-civil rts (all reversals)
logit libvote zsop_phmsm  zmq4_civrts_notmedr mood5208 sgconslib judpower economics civillib if sw_notmedmq8==1 & reversal == 1 & term<2008 & issueArea!=2, cluster(term)
margeff

**MQ civil lib, predicting non-civil lib cases (all reversals)
logit libvote zsop_phmsm zmq4_civlib_notmedr mood5208 sgconslib judpower economics civillib if sw_notmedmq8==1 & reversal == 1 & term<2008 & issueArea!=3 & issueArea!=4 & issueArea!=5 & issueArea!=6, cluster(term)
margeff

**MQ Criminal Proc, predicing non-crim proc. (all reversals)
logit libvote zsop_phmsm zmq4_crimproc_notmedr mood5208 sgconslib judpower economics civillib if sw_notmedmq8==1 & reversal == 1 & term<2008 & issueArea!=1, cluster(term)
margeff

**MQ Econ/Other, predicting non-econ/other (all reversals)
logit libvote zsop_phmsm zmq4_econ_notmedr mood5208 sgconslib judpower economics civillib if sw_notmedmq8==1 & reversal == 1 & term<2008 & issueArea<7, cluster(term)
margeff

drop zmq4_civlib_notmedr zmq4_civrts_notmedr zmq4_crimproc_notmedr zmq4_econ_notmedr 

**type "q" to continue do file
pause

****************************
**Comparison of Median Swing jutice and Most Ideologicla Justices
**When cross-sectional variation of ideology is equivalent
**TABLE A-3
****************************

**Verify that average cross-sectional variance equivalent for two types of justices during this period.
*Position 1
sum cp_reclib if term>=1956 & term<=1970 & pos1mq8==1 & reversal==1
gen p1_n = r(N)
forvalues i = 1956/1970 {
sum cp_reclib if term==`i' & pos1mq8==1 & reversal==1
gen p1_wtdavgsd`i' = (r(N)/p1_n)*r(sd)
}
egen sd=rsum(p1_wtdavgsd1956- p1_wtdavgsd1970)
gen p1_var=sd^2
drop sd
*Median Swing Justice
sum cp_reclib if term>=1956 & term<=1970 & sw_medmq8==1 & reversal==1
gen msj_n = r(N)
forvalues i = 1956/1970 {
sum cp_reclib if term==`i' & sw_medmq8==1 & reversal==1
gen msj_wtdavgsd`i' = (r(N)/msj_n)*r(sd)
}
egen sd=rsum(msj_wtdavgsd1956-msj_wtdavgsd1970)
gen msj_var=sd^2
drop sd
tab p1_var
tab msj_var
drop p1_n- p1_wtdavgsd1970
drop msj_n- msj_wtdavgsd1970
drop p1_var msj_var

**TABLE A-3
logit libvote cp_reclib sgconslib mood5208   zsop_phmsm judpower economics civillib if reversal == 1 & term>=1956 &  term<=1970 & sw_medmq8==1, cluster(term)
margeff

logit libvote cp_reclib sgconslib mood5208   zsop_phmsm judpower economics civillib if reversal == 1 & term>=1956 &  term<=1970 & pos1mq8==1, cluster(term)
margeff

**type "q" to continue do file
pause
****************************
**JUSTICE POSITION VARIABLES: 11 CATEGORY MQ SCORES
****************************
*GENERATE JUSTICE POSITION VARIABLES (by term)
gen pos4mq11 = 0
recode pos4mq11 0=1 if sw_notmedmq11!=1 & mq11_order==4
recode pos4mq11 0=1 if sw_notmedmq11!=1 & mq11_order==6

gen pos3mq11 = 0
recode pos3mq11 0=1 if sw_notmedmq11!=1 & mq11_order==3
recode pos3mq11 0=1 if sw_notmedmq11!=1 & mq11_order==7

gen pos2mq11 = 0
recode pos2mq11 0=1 if sw_notmedmq11!=1 & mq11_order==2
recode pos2mq11 0=1 if sw_notmedmq11!=1 & mq11_order==8

gen pos1mq11 = 0
recode pos1mq11 0=1 if sw_notmedmq11!=1 & mq11_order==1
recode pos1mq11 0=1 if sw_notmedmq11!=1 & mq11_order==9



****************************
**Reversals, ALL Decisions: 11 CATEGORY MQ SCORES
**FIGURE A-6
****************************

**all
egen cplib_rt = std(cp_reclib) if reversal == 1 & term<2008 & totalVotes==9
logit libvote sgconslib mood5208  cplib_rt judpower economics civillib zsop_phmsm if reversal == 1 & term<2008 & totalVotes==9, cluster(term)
margeff
drop cplib_rt
**sw_medmq11
egen cplib_rt = std(cp_reclib) if reversal == 1 & term<2008 & sw_medmq11==1
logit libvote sgconslib mood5208 cplib_rt judpower economics civillib zsop_phmsm if reversal == 1 & term<2008 & sw_medmq11==1, cluster(term)
margeff
drop cplib_rt
**sw_notmedmq11
egen cplib_rt = std(cp_reclib) if reversal == 1 & term<2008 & sw_notmedmq11==1
logit libvote sgconslib mood5208  cplib_rt judpower economics civillib zsop_phmsm if reversal == 1 & term<2008 & sw_notmedmq11==1, cluster(term)
margeff
drop cplib_rt
**pos4mq11
egen cplib_rt = std(cp_reclib) if reversal == 1 & term<2008 & pos4mq11==1
logit libvote sgconslib mood5208 cplib_rt judpower economics civillib zsop_phmsm if reversal == 1 & term<2008 & pos4mq11==1, cluster(term)
margeff
drop cplib_rt
**pos3mq11
egen cplib_rt = std(cp_reclib) if reversal == 1 & term<2008 & pos3mq11==1
logit libvote sgconslib mood5208  cplib_rt judpower economics civillib zsop_phmsm if reversal == 1 & term<2008 & pos3mq11==1, cluster(term)
margeff
drop cplib_rt
**pos2mq11
egen cplib_rt = std(cp_reclib) if reversal == 1 & term<2008 & pos2mq11==1
logit libvote sgconslib mood5208  cplib_rt judpower economics civillib zsop_phmsm if reversal == 1 & term<2008 & pos2mq11==1, cluster(term)
margeff
drop cplib_rt
**pos1mq11
egen cplib_rt = std(cp_reclib) if reversal == 1 & term<2008 & pos1mq11==1
logit libvote sgconslib mood5208  cplib_rt judpower economics civillib zsop_phmsm if reversal == 1 & term<2008 & pos1mq11==1, cluster(term)
margeff
drop cplib_rt

**type "q" to continue do file
pause
****************************
**Reversals, 5-4 Decisions: 11 CATEGORY MQ SCORES
**FIGURE A-7
****************************

**all
egen cplib_rt = std(cp_reclib) if reversal == 1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_rt judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008, cluster(term)
margeff
drop cplib_rt
**sw_medmq11
egen cplib_rt = std(cp_reclib) if reversal == 1 & majVote==5 & minVote==4 & term<2008 & sw_medmq11==1
logit libvote sgconslib mood5208  cplib_rt judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & sw_medmq11==1, cluster(term)
margeff
drop cplib_rt
**sw_notmedmq11
egen cplib_rt = std(cp_reclib) if reversal == 1 & majVote==5 & minVote==4 & term<2008 & sw_notmedmq11==1
logit libvote sgconslib mood5208  cplib_rt judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & sw_notmedmq11==1, cluster(term)
margeff
drop cplib_rt
**pos4mq11
egen cplib_rt = std(cp_reclib) if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos4mq11==1
logit libvote sgconslib mood5208  cplib_rt judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos4mq11==1, cluster(term)
margeff
drop cplib_rt
**pos3mq11
egen cplib_rt = std(cp_reclib) if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos3mq11==1
logit libvote sgconslib mood5208  cplib_rt judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos3mq11==1, cluster(term)
margeff
drop cplib_rt
**pos2mq11
egen cplib_rt = std(cp_reclib) if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos2mq11==1
logit libvote sgconslib mood5208  cplib_rt judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos2mq11==1, cluster(term)
margeff
drop cplib_rt
**pos1mq11
egen cplib_rt = std(cp_reclib) if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos1mq11==1
logit libvote sgconslib mood5208 cplib_rt judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos1mq11==1, cluster(term)
margeff
drop cplib_rt

drop pos4mq11 pos3mq11 pos2mq11 pos1mq11 

**type "q" to continue do file
pause

**************************************
**Time to Join Majority Coalition
**TABLE A-4
**************************************



*Drop unneeded variables and observations to preserve working memory
drop if term<1969
drop if term>1985
drop if majVote!=5
drop if minVote!=4
keep timetomaj justiceName docketId sw_medmq8 sw_notmedmq8 term majVote minVote

save "joinmaj.dta", replace

clear all
set mem 10000k
set maxvar 5000
set matsize 5000
set mem 800000k

use "joinmaj.dta"

**TABLE A-4
xi: nbreg timetomaj i.justiceName i.docketId sw_medmq8 sw_notmedmq8 if timetomaj>0 & timetomaj<=365 & term>=1969 & term<=1985 & majVote==5 & minVote==4

**type "q" to continue do file
pause

prchange

*Alternate quantities of interest:
*prtab sw_medmq8 
*prtab sw_notmedmq8
*nbreg, irr


